package br.com.webcrm.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import br.com.webcrm.dao.TelefoneDAO;
import br.com.webcrm.model.Telefone;

@Repository(value = "telefoneDAO")
public class TelefoneDAOImpl extends BaseDAOImpl<Telefone, Integer> implements TelefoneDAO{

	@Autowired
	public TelefoneDAOImpl(
			@Qualifier("sessionFactory") SessionFactory factory) {
		super.setSessionFactory(factory);
	}
		
	@Override
	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public List<Telefone> consultarPorIdEntidade(Integer idEntidade){
		String[] nomes = {"idEntidade"};
		Object[] valores = {idEntidade};
		return consultarPorNamedQueryEParametros("Telefone.findByIdEntidade", nomes, valores);
	}

}
